<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8" />
    <title>03监听简写</title>
    <script type="text/javascript" src="../js/vue.js"></script>
</head>

<body>
    <div id="demo">
        姓: <input type="text" v-model="firstName"> <br>
        名: <input type="text" v-model="lastName"> <br>
        全称: <span>{{fullName}}</span>
    </div>
    <script type="text/javascript">
        Vue.config.productionTip = false
        new Vue({
            el: '#demo',
            data: {
                firstName:'罗罗诺亚·',
                lastName :'索隆',
                fullName :''
            },
           watch: {
               firstName(value){
                this.fullName = value + '-' + this.lastName;
               },
               lastName(value){
                this.fullName = this.firstName + '-' + value
               }
           }
        })
    </script>
</body>

</html>